#include "SyncEvent.h"

namespace events {


void SyncEvent::saveToStream(std::ostream &os) const {
	os.write(reinterpret_cast<const char*>(&_setype), sizeof(_setype));
	_count.saveToStream(os);
}


void SyncEvent::readFromStream(std::istream &is) {
	is.read(reinterpret_cast<char*>(&_setype), sizeof(_setype));
	_count.readFromStream(is);
}


void SyncEvent::writeDebugInfo(std::ostream &os) const {
	os << "SyncEvent: type=";
	switch (_setype) {
		case SYNC_WAIT_SINGLE:
			os << "WaitForSinleObject";
			break;
		case SYNC_WAIT_SINGLE_EX:
			os << "WaitForSinleObjectEx";
			break;
		case SYNC_WAIT_MULTIPLE:
			os << "WaitForMultipleObjects";
			break;
		case SYNC_WAIT_MULTIPLE_EX:
			os << "WaitForMultipleObjectsEx";
			break;
		case SYNC_MSG_WAIT:
			os << "MsgWaitForMultipleObjects";
			break;
		case SYNC_MSG_WAIT_EX:
			os << "MsgWaitForMultipleObjectsEx";
			break;
		default:
			os << "<Unknown>";
	}
	os << ": handles count=";
	_count.writeDebugInfo(os);
	os << '\n';
}


}  // end namespace